<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        var arr = [1,2,3,1];
        var containsDuplicate = function(nums) {
            if(nums.length==0){
                return false;
            }else{
                for (let i=0;i<nums.length;i++){
                    if(nums.indexOf(nums[i]) != nums.lastIndexOf(nums[i])){
                        return true
                    }
                }
                return false;
            }
        };

        var containsDuplicate1 = function(nums) {
            nums.sort();
            for (let i=0;i<nums.length;i++){
                if(nums[i]==nums[i+1]){
                    return true
                }
            }
            return false
        };
        console.log(containsDuplicate1(arr));

    </script>
</body>
</html>